import subprocess
import time
import random

import config

# 常量配置
from utils import ScreenOperation


def sleep():
    time.sleep(2)


def sleepSetTime(t):
    time.sleep(t)

# 看广告


def doWatch():
    print('开始执行')
    ScreenOperation.closeScreenBrightnessAuto()
    ScreenOperation.setScreenBrightness(0)
    num = 300
    while num > 1:
        ScreenOperation.doTurnThePageDown()
        sleepSetTime(random.randint(5,11))
        num = num - 1
        if num == 1:
            flag = input("本次任务结束，是否继续？0继续，其他退出： ")
            if int(flag) == 0:
                num = 300
                ScreenOperation.closeScreenBrightnessAuto()
                ScreenOperation.setScreenBrightness(0)
            else:
                ScreenOperation.openScreenBrightnessAuto()

if __name__ == '__main__':
    doWatch()